<template>
    <el-dialog
            v-if="processInstanceId"
            title="历史任务"
            :visible.sync="historyTaskDialogVisible"
    >
        <Table
                ref="taskTable"
                :columns="historyColumns"
                :data="$baseURL.workflow +  '/workflow/task/tasks/history/listPage?processInstanceId=' + processInstanceId"
                :show-toolbar="false"
        ></Table>
        <!-- 任务评论弹窗 -->
        <CommentDialog ref="commentDialog" append-to-body  :query-params="commentQueryParams"></CommentDialog>
        <span slot="footer" class="dialog-footer">
    <el-button @click="historyTaskDialogVisible = false">取 消</el-button>
  </span>
    </el-dialog>
</template>

<script>
    import Table from '../../../../common-util/src/components/page/Table.vue'
    import CommentDialog from '../comment/CommentDialog.vue'
    export default {
        name: "HistoryTaskDialog",
        components: {
            Table,
            CommentDialog
        },
        props:{
            processInstanceId:{
                type: String
            }
        },

        data (){
            return {
                historyTaskDialogVisible: false,
                historyColumns:[
                    {
                        type: 'index',
                        label:'序号'
                    },
                    {
                        prop: 'name',
                        label:'任务名称'
                    },
                    {
                        prop: 'assignee.firstName',
                        label:'处理人'
                    },
                    {
                        prop: 'createdStr',
                        label:'任务开始时间'
                    },
                    {
                        prop: 'endDateStr',
                        label:'任务结束时间'
                    },
                    {
                        prop: 'firstCommentMessage',
                        label:'评论',
                        formatType: 'link',
                        link:{
                            action: this.showCommentDialog
                        }
                    }
                ],
                commentQueryParams:{
                    type: 'comment',
                    taskId: null,
                    action: 'AddComment'
                }
            }
        },
        methods:{
            show(){
                this.historyTaskDialogVisible = true
            },
            showCommentDialog(row) {
                this.commentQueryParams.taskId = row.id
                this.$refs.commentDialog.show()
            },
        }
    }
</script>

<style scoped>

</style>